package binary_search;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2024-01-21
 * Time:19:41
 * Text：山脉数组的峰顶索引
 */
public class Text3 {
    public static int peakIndexInMountainArray2(int[] arr) {
        int left=0,right=arr.length-1;
        while(left<right){
            int mid=left+(right-left+1)/2;
            if(arr[mid]>arr[mid-1]){
                left=mid;
            }else {
                right=mid-1;
            }
        }
        return left;
    }
    public static int peakIndexInMountainArray(int[] arr) {
        for(int i=0;i<arr.length-1;i++){
            if(arr[i]>arr[i+1]){
                return i;
            }
        }
        return -1;
    }

    public static void main(String[] args) {

    }
}
